//
//  TransferInfoFooterView.m
//  PigMarket
//
//  Created by mac on 2019/5/8.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import "TransferInfoFooterView.h"

@implementation TransferInfoFooterView
#pragma mark - init method
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initView];
        [self initLayout];
    }
    return self;
}

- (void)initView {
    // 添加子控件
    [self addSubview:self.agreementBtn];
    [self addSubview:self.agreementDetailBtn];
    [self addSubview:self.confirmBtn];

}

- (void)initLayout {
    // 布局子控件
    [self.agreementBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(30);
        make.top.mas_equalTo(17);
        make.height.mas_equalTo(14);
    }];
    [self.agreementDetailBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.agreementBtn.mas_centerY);
        make.left.mas_equalTo(self.agreementBtn.mas_right);
        make.height.mas_equalTo(14);
    }];
    [self.confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.agreementBtn.mas_bottom).offset(20);
        make.centerX.mas_equalTo(self.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(315, 48));
    }];
}
- (void)agreeTapped:(UIButton *)button {
    button.selected = !button.selected;
}
#pragma mark - getter and setter
- (UIButton *)agreementBtn {
    if (!_agreementBtn) {
        _agreementBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_agreementBtn setTitle:@" 我已阅读并同意" forState:UIControlStateNormal];
        [_agreementBtn setTitleColor:[UIColor colorWithHexString:@"#999999"] forState:UIControlStateNormal];
        _agreementBtn.titleLabel.font = [UIFont systemFontOfSize:13];
        [_agreementBtn setImage:[UIImage imageNamed:@"adopt_adoptdetail_agreement"] forState:UIControlStateNormal];
        [_agreementBtn setImage:[UIImage imageNamed:@"adopt_adoptdetail_agreement_selected"] forState:UIControlStateSelected];
//        [_agreementBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 4 * [JTool getScreenWidthScale], 0, -4 * [JTool getScreenWidthScale])];
        [_agreementBtn addTarget:self action:@selector(agreeTapped:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _agreementBtn;
}
- (UIButton *)agreementDetailBtn {
    if (!_agreementDetailBtn) {
        _agreementDetailBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_agreementDetailBtn setTitle:@"《转让协议》" forState:UIControlStateNormal];
        _agreementDetailBtn.titleLabel.font = [UIFont systemFontOfSize:13];
        [_agreementDetailBtn setTitleColor:[UIColor primaryColor] forState:UIControlStateNormal];
    }
    return _agreementDetailBtn;
}
- (UIButton *)confirmBtn {
    if (!_confirmBtn) {
        _confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_confirmBtn setBackgroundImage:[UIImage imageNamed:@"login_loginbtn_default"] forState:UIControlStateNormal];
        [_confirmBtn setTitle:@"确认转让" forState:UIControlStateNormal];
    }
    return _confirmBtn;
}
@end
